#ifndef QLOGMGR_H
#define QLOGMGR_H
#include"log4qt/logger.h"
#include"log4qt/consoleappender.h"
#include"log4qt/patternlayout.h"
#include"log4qt/propertyconfigurator.h"
#include"log4qt/logmanager.h"
#include"log4qt/fileappender.h"
#include"log4qt/rollingfileappender.h"
#include"log4qt/varia/levelrangefilter.h"
#include<QThread>

class WorkerThread : public QThread
{
private:
    void run() override
    {
        Log4Qt::Logger* logger = Log4Qt::Logger::logger("WorkerThread");
        for (int i = 0; i < 5; ++i)
        {
            QString strInfo = QString::asprintf("Thread %p processing task %d",QThread::currentThreadId(),i);
            logger->info(strInfo);

            QThread::msleep(100); // 模拟工作

            QString str1 = QString::asprintf("Thread %p processing Task %d completed",QThread::currentThreadId(),i);
            logger->info(str1);
        }

        QString str = QString::asprintf("Worker thread %p finished",QThread::currentThreadId());
        logger->info(str);
    }
};

class QLogMgr
{
public:
    QLogMgr();
    ~QLogMgr();
    // 配置日志
    void setUpDetailLogging();

    void demoLogging();
    // 多线程日志
    void demoMultiThreadLogging();
    // 高级日志
    void setupAdvancedLogging();
};

#endif // QLOGMGR_H
